#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "UI/DebugForm.h"
#include "DeviceControl.h"
#include "UI/ParaView.h"
#include <QListWidgetItem>
#include <QScrollArea>
#include <QToolBar>
#include <QRadioButton>
#include "src/Widget/ListItem/ItemBody.h"
#include "src/Widget/ListItem/ItemDelegate.h"
#include "src/Widget/ListItem/ItemModel.h"
#include "src/Widget/ZListStatusWidget.h"
#include "src/Manager/AppManager.h"
#include "src/Widget/QCvDisplay.h"
#include "UI/AboutForm.h"
#include "UI/SeamWeldForm.h"
#include "UI/LocalPara.h"
#include "UI/DeviceLogin.h"


QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();




private slots:

    void on_actionView_triggered();

    void on_actionCleanTask_triggered();

    void on_actionStartGrab_toggled(bool arg1);

    void on_actionWeldPara_triggered();

    void on_action3D_triggered();

    void on_actionImg_triggered();

    void on_actionDebug_triggered();

    void on_actionOpenDebug_triggered();

    void on_actionLocalPara_triggered();

    void on_actionChart_triggered();

    void on_actionOpenLaser_triggered(bool checked);

    void on_actionExit_triggered();

    // void on_actionOpenLaser_triggered();

    void on_actionLink_triggered();

    void on_pb_Diagnosis_clicked();

private:
    Ui::MainWindow *ui;
    QLabel  *curMouse;
    DebugForm debugForm;
    AboutForm aboutForm;
    DeviceLogin connectForm;

    LocalPara * localView;
    ParaView  * paraMentView;
    SeamWeldForm *seamView;
    QToolBar *controlBar;

    QCvDisplay *dis;                 /* 图像的显示窗体 */

    Singleton<Camera> _camera ;
    Singleton<RobotLaser> _laser ;
    Singleton<mbControl> _mb_ptr;


    QMap<QString ,BodyWidget*> statusWidget;

private:
    std::atomic<bool> camShow =  ATOMIC_FLAG_INIT;         /// 暂时未使用
    std::atomic<int>  auxiliary = {-1};         // 辅助 -1.没有选择  0.不显示  1.显示辅助线  2.显示格点  3全都显示



private:
    void reflushUI();
    /**
     * @brief initMembers
     * @details 连接异常显示信号
     */
    void initMembers();

    /**
     * @brief PosToUI
     * @param pos
     * @param axis
     * @details 更新界面上的UI显示
     */
    void PosToUI(RobotPos pos, RobotAxle axis);
    /**
     * @brief initUIs
     * @details
     * 初始化UI控件
     */
    void initUIs();
    /**
     * @brief initToolBar
     * @details 初始化工具栏
     */
    void initToolBar();

    /**
     * @brief creatCameraTools
     * @details 创建相机的辅助按钮
     */
    void creatCameraTools();
};
#endif // MAINWINDOW_H
